package com.test.p02simplefactory.example01;

/**
 * 水果园丁
 * @author bcc
 */
public class FruitGardener {

    public static final String APPLE = "apple";
    public static final String STRAWBERRY = "strawberry";
    public static final String GRAPE = "grape";

    public static Fruit factory(String type) throws BadFruitException{
        if(APPLE.equals(type)){
            return new Apple();
        }else if (STRAWBERRY.equals(type)){
            return new Strawberry();
        }else if(GRAPE.equals(type)){
            return new Grape();
        }else{
            throw new BadFruitException("Bad fruit request");
        }

    }
}
